//
// DotNetNuke - http://www.dotnetnuke.com
// Copyright (c) 2002-2010
// by Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using DotNetNuke.Entities.Users;
using DotNetNuke.Security.Membership;
namespace DotNetNuke.Entities.Modules
{
	public class UserUserControlBase : UserModuleBase
	{
		public delegate void UserCreatedEventHandler(object sender, UserCreatedEventArgs e);
		public delegate void UserDeletedEventHandler(object sender, UserDeletedEventArgs e);
		public delegate void UserRestoredEventHandler(object sender, UserRestoredEventArgs e);
		public delegate void UserRemovedEventHandler(object sender, UserRemovedEventArgs e);
		public delegate void UserUpdateErrorEventHandler(object sender, UserUpdateErrorArgs e);
		public event UserCreatedEventHandler UserCreated;
		public event UserCreatedEventHandler UserCreateCompleted;
		public event UserDeletedEventHandler UserDeleted;
		public event UserUpdateErrorEventHandler UserDeleteError;
		public event UserRestoredEventHandler UserRestored;
		public event UserUpdateErrorEventHandler UserRestoreError;
		public event UserRemovedEventHandler UserRemoved;
		public event UserUpdateErrorEventHandler UserRemoveError;
		public event EventHandler UserUpdated;
		public event EventHandler UserUpdateCompleted;
		public event UserUpdateErrorEventHandler UserUpdateError;
		public void OnUserCreateCompleted(UserCreatedEventArgs e)
		{
			if (UserCreateCompleted != null)
			{
				UserCreateCompleted(this, e);
			}
		}
		public void OnUserCreated(UserCreatedEventArgs e)
		{
			if (UserCreated != null)
			{
				UserCreated(this, e);
			}
		}
		public void OnUserDeleted(UserDeletedEventArgs e)
		{
			if (UserDeleted != null)
			{
				UserDeleted(this, e);
			}
		}
		public void OnUserDeleteError(UserUpdateErrorArgs e)
		{
			if (UserDeleteError != null)
			{
				UserDeleteError(this, e);
			}
		}
		/// -----------------------------------------------------------------------------
		/// <summary>
		/// Raises the UserRestored Event
		/// </summary>
		/// <history>
		/// 	[aprasad]	02/15/2011  Created
		/// </history>
		/// -----------------------------------------------------------------------------
		public void OnUserRestored(UserRestoredEventArgs e)
		{
			if (UserRestored != null)
			{
				UserRestored(this, e);
			}
		}

		/// -----------------------------------------------------------------------------
		/// <summary>
		/// Raises the OnUserRestoreError Event
		/// </summary>
		/// <history>
		/// 	[aprasad]	02/15/2011  Created
		/// </history>
		/// -----------------------------------------------------------------------------
		public void OnUserRestoreError(UserUpdateErrorArgs e)
		{
			if (UserRestoreError != null)
			{
				UserRestoreError(this, e);
			}
		}

		/// -----------------------------------------------------------------------------
		/// <summary>
		/// Raises the UserRemoved Event
		/// </summary>
		/// <history>
		/// 	[aprasad]	02/15/2011  Created
		/// </history>
		/// -----------------------------------------------------------------------------
		public void OnUserRemoved(UserRemovedEventArgs e)
		{
			if (UserRemoved != null)
			{
				UserRemoved(this, e);
			}
		}

		/// -----------------------------------------------------------------------------
		/// <summary>
		/// Raises the OnUserRemoveError Event
		/// </summary>
		/// <history>
		/// 	[aprasad]	02/15/2011  Created
		/// </history>
		/// -----------------------------------------------------------------------------
		public void OnUserRemoveError(UserUpdateErrorArgs e)
		{
			if (UserRemoveError != null)
			{
				UserRemoveError(this, e);
			}
		}
		public void OnUserUpdated(EventArgs e)
		{
			if (UserUpdated != null)
			{
				UserUpdated(this, e);
			}
		}
		public void OnUserUpdateCompleted(EventArgs e)
		{
			if (UserUpdateCompleted != null)
			{
				UserUpdateCompleted(this, e);
			}
		}
		public void OnUserUpdateError(UserUpdateErrorArgs e)
		{
			if (UserUpdateError != null)
			{
				UserUpdateError(this, e);
			}
		}
		public class BaseUserEventArgs
		{
			private string _userName;
			private int _userId;
			public BaseUserEventArgs()
			{
			}
			public int UserId
			{
				get { return _userId; }
				set { _userId = value; }
			}
			public string UserName
			{
				get { return _userName; }
				set { _userName = value; }
			}
		}
		public class UserCreatedEventArgs
		{
			private UserInfo _NewUser;
			private UserCreateStatus _CreateStatus = UserCreateStatus.Success;
			private bool _Notify = false;
			public UserCreatedEventArgs(UserInfo newUser)
			{
				_NewUser = newUser;
			}
			public UserCreateStatus CreateStatus
			{
				get { return _CreateStatus; }
				set { _CreateStatus = value; }
			}
			public UserInfo NewUser
			{
				get { return _NewUser; }
				set { _NewUser = value; }
			}
			public bool Notify
			{
				get { return _Notify; }
				set { _Notify = value; }
			}
		}
		public class UserDeletedEventArgs : BaseUserEventArgs
		{
			public UserDeletedEventArgs(int id, string name)
			{
				UserId = id;
				UserName = name;
			}
		}

		/// -----------------------------------------------------------------------------
		/// <summary>
		/// The UserRestoredEventArgs class provides a customised EventArgs class for
		/// the UserRestored Event
		/// </summary>
		/// <history>
		/// 	[aprasad]	02/15/2011  created
		/// </history>
		/// -----------------------------------------------------------------------------
		public class UserRestoredEventArgs : BaseUserEventArgs
		{

			/// -----------------------------------------------------------------------------
			/// <summary>
			/// Constructs a new UserRestoredEventArgs
			/// </summary>
			/// <param name="id">The Id of the User</param>
			/// <param name="name">The user name of the User</param>
			/// <history>
			/// 	[aprasad]	02/15/2011  created
			/// </history>
			/// -----------------------------------------------------------------------------
			public UserRestoredEventArgs(int id, string name)
			{
				UserId = id;
				UserName = name;
			}

		}


		/// -----------------------------------------------------------------------------
		/// <summary>
		/// The UserRestoredEventArgs class provides a customised EventArgs class for
		/// the UserRestored Event
		/// </summary>
		/// <history>
		/// 	[aprasad]	02/15/2011  created
		/// </history>
		/// -----------------------------------------------------------------------------
		public class UserRemovedEventArgs : BaseUserEventArgs
		{

			/// -----------------------------------------------------------------------------
			/// <summary>
			/// Constructs a new UserRemovedEventArgs
			/// </summary>
			/// <param name="id">The Id of the User</param>
			/// <param name="name">The user name of the User</param>
			/// <history>
			/// 	[aprasad]	02/15/2011  created
			/// </history>
			/// -----------------------------------------------------------------------------
			public UserRemovedEventArgs(int id, string name)
			{
				UserId = id;
				UserName = name;
			}

		}
		public class UserUpdateErrorArgs : BaseUserEventArgs
		{
			private string _message;
			public UserUpdateErrorArgs(int id, string name, string message)
			{
				UserId = id;
				UserName = name;
				_message = message;
			}
			public string Message
			{
				get { return _message; }
				set { _message = value; }
			}
		}
	}
}
